package qz_rpt

import java.text.SimpleDateFormat

class PartListController {

    def commonSqlService
    def dynamicQueryService

    def partList() {
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 100
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        SimpleDateFormat sdf = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss')
        def startTime = params.startTime ? sdf.parse(params.startTime) : sdf.parse(sdf.format(new Date().clearTime()))
        def endTime = params.endTime ? sdf.parse(params.endTime) : sdf.parse(sdf.format(new Date()))
        params.startTime = sdf.format(startTime)
        params.endTime = sdf.format(endTime)
        def partFinSum=[]
        def tableHeadList=[]
        def partList=[]
        def list=[]
        def pageSizeList = [10,20,50,100]
        def totalCount =0
//        def customerLotIdList = commonSqlService.customerLotIdList(params)
        if(params.EXPORT_CONTENT_NAME=='Excel'){
            println(params.startTime)
            params.SYS_QUERY_NAME = 'partList'
            partList = dynamicQueryService.queryForList(params)

            tableHeadList = []
            if (partList.size() > 0) {
                tableHeadList = partList[0].keySet()
            }

            params.SYS_QUERY_NAME = 'partListCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
//            params.SYS_QUERY_NAME = 'orderStatusAnalysisSum'
//            orderStatusAnalysisSum = dynamicQueryService.queryForList(params)

        }
        [pageSize     : pageSize, totalCount: totalCount, pageSizeList: pageSizeList,pageCurrent:pageCurrent,
//         customerLotIdList:customerLotIdList,
         customerLotId:params.customerLotId?:'',
         partFinSum:partFinSum,tableHeadList:tableHeadList,partList:partList,tableHeadList:tableHeadList,startno: params.startno?:'',endno:params.endno?:'',
         startTime:params.startTime?:'',endTime:params.endTime?:'',group3:params.group3?:'',tdry:params.tdry?:'',cate:params.cate?:'',fsgw:params.fsgw?:'']
    }


}
